<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>axios基本url设置</title>
	</head>
	<body>
		<script src="../js/axios.js">
			
		</script>
		
		<script type="text/javascript">
			/*
			 * 请求类型:post/put
			 * 1.对象提交方式
			 */
			axios.defaults.baseURL="http://localhost:8090"
			axios.post("addUser1",{
				name:"隐性刺客",
				age:30,
				sex:"男"
			}).then(result=> {
				console.log("插入成功")
				console.log(result.data)
			})
			/**
			 * 2.axios利用form表单提交数据
			 */
			let params = new URLSearchParams();
			params.append("name","矮人直升机")
			params.append("age",40)
			params.append("sex","男")
			axios.post("/addUserForm",params).then(result =>{
				console.log("form表单提交成功")
				console.log(result.data)
			})
			/**
			 * 3.restFul方式实现表单数据提交
			 */
			axios.post("user/敌法师/28/男").then(result => {
				alert("resFul实现数据提交")
				console.log(result.data)
			})
			/**
			 * put请求
			 * 修改id=250的name="大地之灵",要求使用restFul风格
			 */
			axios.put("/user/250/大地之灵").then(result => {
				console.log("restFul实现数据更改")
				console.log(result.data)
			})
		</script>
	</body>
</html>
